home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-09 | 2.7 KB | 103 lines | [TEXT/KAHL] |
- /****
- * CNeoDemoScrollPane.c
- *
- * Copyright © 1992 NeoLogic Systems. All rights reserved.
- *
- ****/
-
- #include "NeoTypes.h"
- #include "Constants.h"
- #include "CScrollBar.h"
- #include "CNeoDemoDoc.h"
- #include "CNeoDLOGDialog.h"
- #include "CNeoDemoScrollPane.h"
-
- /******************************************************************************
- DoHorizScroll
-
- Horizontally scroll the Panorama associated with a ScrollPane
- ******************************************************************************/
-
- void CNeoDemoScrollPane::DoHorizScroll(short whichPart)
- {
- short delta; /* percent of total to scroll */
- short val; /* percemt of total at which to set position */
- long ticks; /* Tick count at end of Delay */
- short nPicts;
- CNeoDemoDoc * document = ((CNeoDemoDoc *)((CNeoDLOGDialog *)itsSupervisor)->itsSupervisor);
-
- nPicts = document->getImageCount();
- switch (whichPart) {
- case inUpButton:
- delta = -hStep;
- break;
-
- case inDownButton:
- delta = hStep;
- break;
-
- case inPageUp:
- Delay(PAGE_DELAY, &ticks);
- delta = -hStep; /* page goes 1 pictures at a time */
- break;
-
- case inPageDown:
- Delay(PAGE_DELAY, &ticks);
- delta = hStep;
- break;
- }
-
- val = itsHorizSBar->GetValue();
- val += delta;
-
- if ((nPicts < 2) ||
- (val<0))
- val = 0;
- else
- if (val >= nPicts)
- val = nPicts-1;
-
- DoNDScroll(val+1);
-
- itsHorizSBar->Prepare();
- }
-
-
- /******************************************************************************
- DoThumbDrag
-
- Adjust associated Panorama when the thumb of a scroll bar is dragged
- ******************************************************************************/
-
- void CNeoDemoScrollPane::DoThumbDrag(short hDelta, short vDelta)
- {
- short val;
- short nPicts;
- CNeoDemoDoc * document = ((CNeoDemoDoc *)((CNeoDLOGDialog *)itsSupervisor)->itsSupervisor);
-
- nPicts = document->getImageCount();
- /* Because of the scaling of control values when using long coordinates */
- /* dragging the thumb to the beginning or end of the scroll bar will */
- /* sometimes not fully scroll to the beginning or end. Catch this by */
- /* checking if the current value is the max or min. */
-
- val = itsHorizSBar->GetValue();
- DoNDScroll(val+1);
- }
-
- /******************************************************************************
- DoScroll
-
- Set correct PICT. All scrolling bottlenecks through this method.
- ******************************************************************************/
-
- void CNeoDemoScrollPane::DoNDScroll(short val)
- {
- CNeoDemoDoc * document = ((CNeoDemoDoc *)((CNeoDLOGDialog *)itsSupervisor)->itsSupervisor);
-
- document->updateImage(nil); /* save any edited text info */
-
- document->gotoImage(val, TRUE); /* setup new image and redraw it immediately */
-
- }
-